﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using OnlineMovieTicket.Services.IServices;
using OnlineMovieTicket.Services.Services;
using OnlineMovieTicket.Model;
using OnlineMovieTicket.ViewModels;
using System.Data.SqlClient;

namespace OnlineMovieTicket.Controllers
{
    public class BestMoviesController : Controller
    {
        //
        // GET: /BestMovies/
        ITopTenMoivesService topTenMovieSrv;

           public BestMoviesController()
        {
             topTenMovieSrv = new TopTenMoviesService();
        }

        public BestMoviesController(ITopTenMoivesService serv)
        {
            topTenMovieSrv=serv;
        }
        public ActionResult Search()
        {
            ITopTenMoivesService movieSrv = new TopTenMoviesService();


            MoviesStatisticsSearchModel s = new MoviesStatisticsSearchModel();

            return View(s);
        }
        [HttpPost]
        public ActionResult Search(MoviesStatisticsSearchModel s)
        {
            //IMovieAssignmentService movieAssignSrv = new MovieAssignmentService();
            IList<Model.TopTenMoviesDetail> data = topTenMovieSrv.GetTopTenMoviesByRating(s.StartDate, s.EndDate);
            
            if (Request.IsAjaxRequest())
                return View("SearchResult", data);
            else
                return View(data);
        }

      
    }
}
